package com.ship.contract.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ship.contract.bean.ConShipping;
import com.ship.contract.bean.vo.ConShippingNameTextVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface ConShippingMapper extends BaseMapper<ConShipping> {

    /**
     * 根据id查询所有信息
     */
    @Select("SELECT * FROM con_shipping WHERE id = #{id}")
    ConShipping getById(@Param("id") Long id);

    /**
     * 获取所有合同编号
     * @return
     */
    @Select("SELECT contract_number FROM con_shipping")
    List<String> getAllContractNumbers();

    List<String> queryShipNameList(@Param("shipName") String shipName);

    /**
     * 获取所有船级社
     * @return
     */
    @Select("select classification_society as nameText,classification_society as nameValue from con_shipping GROUP BY classification_society")
    List<ConShippingNameTextVo> getAllClassificationSociety();

    /**
     * 获取所有船东
     * @return
     */
    @Select("select shipowner as nameText,shipowner as nameValue from con_shipping GROUP BY shipowner")
    List<ConShippingNameTextVo> getAllShipowner();

    /**
     * 获取所有租家
     * @return
     */
    @Select("select tenant as nameText,tenant as nameValue from con_shipping GROUP BY tenant")
    List<ConShippingNameTextVo> getAllTenant();

    /**
     * 获取所有航运经纪人
     * @return
     */
    @Select("select ship_broker as nameText,ship_broker as nameValue from con_shipping GROUP BY ship_broker")
    List<ConShippingNameTextVo> getAllShipBroker();
}
